package org.anderground.editor.gui.view.android;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import org.anderground.core.Logger;
import org.anderground.core.drawer.MetroDrawer;

/**
 * @author Ilya Shurigyn (honorik@gmail.com)
 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
 */
public class DrawersRegistry {

	/**
	 * @author Eldar Abusalimov (eldar.abusalimov@gmail.com)
	 */
	public static class DrawerEntry {

		private Class<? extends MetroDrawer> drawerClass;

		private String name;

		/**
		 * 
		 * @param drawerClass
		 * @param name
		 */
		private DrawerEntry(Class<? extends MetroDrawer> drawerClass,
				String name) {
			this.drawerClass = drawerClass;
			this.name = name;
		}

		/**
		 * @return the drawerClass
		 */
		public Class<? extends MetroDrawer> getDrawerClass() {
			return drawerClass;
		}

		/**
		 * @return the drawerName
		 */
		public String getName() {
			return name;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj instanceof DrawerEntry) {
				return drawerClass.equals(((DrawerEntry) obj).drawerClass);
			}
			return false;
		}

		@Override
		public int hashCode() {
			return drawerClass.hashCode() + 1;
		}

	}

	private static Set<DrawerEntry> entries = new HashSet<DrawerEntry>();

	/**/

	public static void registerDrawer(Class<? extends MetroDrawer> drawerClass,
			String name) {
		Logger.i("registering new drawer: " + name);
		entries.add(new DrawerEntry(drawerClass, name));
	}

	public static List<DrawerEntry> getEntries() {
		return new LinkedList<DrawerEntry>(entries);
	}

}
